<template>
  <div class="app-container">
    <wise-crud
      ref="wise-crud"
      :urls="urls"
      :fields="fields"
      :handle="handle"
      :filters="filters"
    />
  </div>
</template>
<script>
import WiseCrud from '@/components/Crud/wiseCrud'
import { getEntSpaceId } from '@/utils/auth'
export default {
  name: 'FacilityManage',
  components: { WiseCrud },
  data() {
    return {
      urls: {
         list: '/api/v1/welder-sbtx-second/video-comb/listqy1',
        add: '/api/v1/welder-sbtx-second/video-comb/createx',
        show: '/api/v1/welder-sbtx-second/video/show/',
        update: '/api/v1/welder-sbtx-second/video-comb/update/',
        delete: '/api/v1/welder-sbtx-second/video/remove/'
      }
    }
  },
  computed: {
    spaceId() {
      return this.$store.state.project.spaceId
    },
    entSpaceId() {
      return getEntSpaceId()
    },
    handle() {
      // if (this.$store.state.user.project) {
      //   return ['add']
      // } else {
      //   return ['add', 'filters']
      // }'add'
       return []
    },
    fields() {
      let arr = [{ label: '序号', type: 'index', use: ['table'] }]
      arr.push(
        { 
          label: '摄像头名称',
          prop: 'name',
          type: 'select',
          url: '/api/v1/welder-sbtx-second/video-comb/listqy1x',
          labelKey: 'name',
          valueKey: 'id',
          objKeys: [
            {
              field: 'equipmentId',
              key: 'id'
            }
          ],
          filters: [
            { field: 'st', operator: 'NE', value: 9 },
            {
              field: 'entSpaceId',
              operator: 'EQUALS',
              value: this.entSpaceId
            }
          ],
          rules: [
            { required: true, message: '请选择设备名称', trigger: 'change' }
          ],
          // use: ['add', 'view', 'edit']
          use: ['table','add'  ]
        },
        {
          label: '视频名称',
          prop: 'name',
          type: 'text',
          labelWidth: '130px',
          use: [  'edit']
        },
        {
          label: '视频URL地址',
          prop: 'url',
          type: 'text',
          labelWidth: '130px',
          // use: ['table', 'view', 'search']
          use: ['view', 'edit']
        },
      
        {
          label: 'appKey',
          prop: 'appKey',
          type: 'text',
          labelWidth: '130px',
          use: [  'view', 'edit']
        },
        {
          label: 'appSecret',
          prop: 'appSecret',
          type: 'text',
          labelWidth: '130px',
          use: [  'view', 'edit']
        },
        {
          label: '设备序列号',
          prop: 'deviceSerial',
          type: 'text',
          labelWidth: '130px',
          use: [  'view', 'edit']
        },
        //内网去除
        // {
        //   label: '通道号',
        //   prop: 'channelNo',
        //   type: 'text',
        //   labelWidth: '130px',
        //   use: ['table', 'view', 'edit']
        // },
        {
          label: '摄像头类型',
          prop: 'typeCode',
          type: 'render',
          type: 'radio',
          dataDic: 'cameraType',
          labelWidth: '130px',
          use: [ 'table', 'view', 'edit']
        },
        {
          label: '视频顺序',
          prop: 'sequence',
          type: 'number',
          labelWidth: '130px',
          rules: [
            { required: true, message: '请输入视频顺序', trigger: 'change' }
          ],
          placeholder: '请输入视频顺序',
          use: ['table', 'view', 'edit']
        },{
          label: '内网视频地址',
          prop: 'nwurl',
          type: 'text',
          labelWidth: '130px',
          rules: [
            { required: true, message: '请输入视频顺序', trigger: 'change' }
          ],
          placeholder: '请输入视频顺序',
          use: ['table', 'view', 'edit']
        },
        //内网去除
        // {
        //   label: '内网通道号',
        //   prop: 'nwtd',
        //   type: 'number',
        //   labelWidth: '130px',
          
        //   use: ['table', 'view', 'edit']
        // },
        {
          prop: 'spaceId',
          
          use: ['add', 'edit', 'edit']
        }
      )
      arr.push({
        label: '操作',
        type: 'handle',
        use: ['table'],
        handle: ['view',  'delete'],
        tableWidth: 300
      })
      return arr
    },
    filters() {
      return [
        {
          field: 'spaceId',
          operator: 'EQUALS',
          value: this.$store.state.project.spaceId
        }
      ]
    }
  },
  mounted() {
 
  },
  methods: {}
}
</script>

<style>
</style>
